using System.Collections.Generic;
using System.Linq;

namespace PCE.Domain
{
	public class Customer : Entity
	{
		private readonly ISet<Tender> _tenders = new HashSet<Tender>();
		
		public virtual string Login { get; set; }

		public virtual string Email { get; set; }

		public virtual string Password { get; set; }

		public virtual bool IsCorporate { get; set; }

		public virtual string CompanyName { get; set; }

		public virtual string LegalAddress { get; set; }

		public virtual string PhysicalAddress { get; set; }

		public virtual string TIN { get; set; }

		public virtual string BIN { get; set; }

		public virtual Ownership Ownership { get; set; }

		public virtual IEnumerable<Tender> Tenders
		{
			get { return _tenders; }
		}

		public virtual void AddTender(Tender tender)
		{
			_tenders.Add(tender);
			tender.SetCustomer(this);
		}

		public virtual void UpdateTender(Tender tender)
		{
			var old = _tenders.Single(t => t.Id == tender.Id);
			_tenders.Remove(old);
			_tenders.Add(tender);
			tender.SetCustomer(this);
		}
	}
}